﻿@{
    ViewBag.Title = "Index";
}
@using KingRoad.EPM.Common.Helper
<script type="text/javascript">
    var zNodes_permission_Instructions_index = [];
    var zTree_permission_Instructions_index;
    var setting_permission_Instructions_index;
    var zTree_Instructions_Index;
    var zNodes_Instructions_Index = [];
    var MoudleID = "";
    //全局的href
    var href__permission_module_index = "/Permission/Instructions";
    function zTree() {
        setting_permission_Instructions_index = {
            checkable: false,
            async: true,
            isSimpleData: true,
            editable: true,
            edit_removeBtn: false,
            edit_renameBtn: false,
            dragCopy: true,
            dragMove: true,
            asyncUrl: "/Permission/Instructions/GetModuleMenus",
            nameCol: "FullName",
            open: false,
            treeNodeKey: "Id",
            treeNodeParentKey: "ParentId",
            callback: {
                asyncSuccess: zTreeOnAsyncSuccess_permission_module_index,
                click: zTreeOnClick_permission_module_index
            }
        };
    }

    function zTreeOnAsyncSuccess_permission_module_index(event, treeId, treeNode, msg) {

    }
    //树的单击事件
    function zTreeOnClick_permission_module_index(event, treeId, treeNode) {
        MoudleID = treeNode.Id;
        $("#add_permission_instructions_index").attr("href", "/Permission/Instructions/Creat/" + treeNode.Id);
        $("#rightDetail_permission_Instructions_index").html("").load("/Permission/Instructions/InstructionsList/" + MoudleID);
    }
    //页面加载完成事件
    $(function () {
        zTree();
        zTree_Instructions_Index = $("#treeModule_permission_Instructions_index").zTree(setting_permission_Instructions_index, zNodes_Instructions_Index);
    });
    function Instructions_Create_Callback(json) {
        //提交回调
        //1 接收参数 2 判断成功与否
        DWZ.ajaxDone(json);
        if (json.statusCode == DWZ.statusCode.ok) {
            //添加成功            
            alertMsg.correct(json.message);
            $("#rightDetail_permission_Instructions_index").html("").load("/Permission/Instructions/InstructionsList/" + MoudleID);
        }
        else {
            alertMsg.error(json.message);
        }
        $.pdialog.closeCurrent();
        $("#background,#progressBar,#lui_RoleTable").hide();
    }
    function fun_EditData_InstructionsList_index(id) {
        var _Str = "编辑";
        $.pdialog.open("/Permission/Instructions/Edit?id=" + id, "", _Str, { "mask": "true", width: 650, height: 550 });
    }
    function fun_DeleteData_InstructionsList_index(id) {
        alertMsg.confirm("确认删除？", {
            okCall: function () {
                $.post("/Permission/Instructions/Delete", { "id": id }, function (json) {
                    //1 接收参数 2 判断成功与否 3 根据返回的数据在树上新增节点
                    DWZ.ajaxDone(json);
                    if (json.statusCode == DWZ.statusCode.ok) {
                        $("#rightDetail_permission_Instructions_index").html("").load("/Permission/Instructions/InstructionsList/" + MoudleID);
                    }
                    else {
                        alertMsg.error("删除失败,请稍后再试！");
                    }
                }, "json");
            }
        });
    }
</script>
<div class="page">
    @*顶部按钮*@
    <div class="panelBar">
        <ul class="toolBar">
            <li>@Html.PermissionButton("Permission.Instructions.Create", "add_permission_instructions_index", "add", "/Permission/Instructions/Creat/{sid_user}", "new", "dialog", "添加说明", "true", "550", "400", "添加")</li>
            <li class="line">line</li>
        </ul>
    </div>
    <div id="mainContent_permission_Instructions_index">
        <div layouth="32" class="leftPanel">
            @*菜单树*@
            <ul id="treeModule_permission_Instructions_index" class="ztree">
            </ul>
        </div>
        <div class="rightPanel">
            <div id="rightDetail_permission_Instructions_index">
            </div>
        </div>
    </div>
</div>
